﻿<%@ CodePage=65001   Language=VBScript  %> 
<!--#include file=MD5.asp-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta http-equiv="Content-Language" content="zh-CN"/>
	<meta http-equiv="Expires" content="0" />        
	<meta http-equiv="Cache-Control" content="no-cache" />        
	<meta http-equiv="Pragma" content="no-cache" />
	<title>通联网上支付平台-商户接口范例-支付结果</title>
	</head>
<body>
<%

	merchantId		=Request("merchantId")
	version			=Request("version")
	language		=Request("language")
	signType		=Request("signType")
	payType			=Request("payType")	
	issuerId		=Request("issuerId")
	paymentOrderId	        =Request("paymentOrderId")
	orderNo			=Request("orderNo")
	orderDatetime	        =Request("orderDatetime")
	orderAmount		=Request("orderAmount")
	payDatetime		=Request("payDatetime")
	payAmount		=Request("payAmount")
	ext1			=Request("ext1")
	ext2			=Request("ext2")
	payResult		=Request("payResult")
	errorCode		=Request("errorCode")
	returnDatetime	        =Request("returnDatetime")
	signMsg			=Request("signMsg")
	md5Key = "1234567890"

	'验签是商户为了验证接收到的报文数据确实是支付网关发送的。
	'构造订单结果对象，验证签名。
		Dim bufSignSrc
		bufSignSrc=""
		
        bufSignSrc=appendSignPara(bufSignSrc, "merchantId",merchantId)
        bufSignSrc=appendSignPara(bufSignSrc, "version", version)
        bufSignSrc=appendSignPara(bufSignSrc, "language", language)
        bufSignSrc=appendSignPara(bufSignSrc, "signType", signType)
		bufSignSrc=appendSignPara(bufSignSrc, "payType", payType)
        bufSignSrc=appendSignPara(bufSignSrc, "issuerId", issuerId)
        bufSignSrc=appendSignPara(bufSignSrc, "paymentOrderId", paymentOrderId)
        bufSignSrc=appendSignPara(bufSignSrc, "orderNo", orderNo)
        bufSignSrc=appendSignPara(bufSignSrc, "orderDatetime", orderDatetime)
		bufSignSrc=appendSignPara(bufSignSrc, "orderAmount", orderAmount)
        bufSignSrc=appendSignPara(bufSignSrc, "payDatetime", payDatetime)
        bufSignSrc=appendSignPara(bufSignSrc, "payAmount", payAmount)
        bufSignSrc=appendSignPara(bufSignSrc, "ext1", ext1)
        bufSignSrc=appendSignPara(bufSignSrc, "ext2", ext2)
        bufSignSrc=appendSignPara(bufSignSrc, "payResult", payResult)
        bufSignSrc=appendSignPara(bufSignSrc, "errorCode", errorCode)
        bufSignSrc=appendSignPara(bufSignSrc, "returnDatetime", returnDatetime)
        bufSignSrc=appendLastSignPara(bufSignSrc, "key", md5Key)
				
		srcMsg = bufSignSrc  '此方法用于debug，测试通过后可注释。
		signMsg_new = MD5(srcMsg) '签名，设为signMsg字段值。
		Response.write("signMsg_new=" & signMsg_new & "</br>") '商户组签名原串，用md5生成签名串
		Response.write("signMsg=" & signMsg) '接收服务端签名串
		
		Dim verifyResult 
		verifyResult = "failture"
		'比较signMsg和signMsg_new，两字符相等说明验签成功，还需要判断订单状态，为"1"表示支付成功，
		if signMsg = signMsg_new And payResult = "1" then
		'TODO 商户订单处理，显示客户订单付款成功页面
		verifyResult = "success"
		End If

%>
	<center> <font size=16><strong>支付结果</strong></font></center>
	<div style="padding-left:50px;">
	 		<div>验签结果：<%=verifyResult%> </div>
			<div>&nbsp;</div>
			<div>商户号：<%=merchantId%> </div>
			<div>商户订单号：<%=orderNo%> </div>
			<div>商户订单金额：<%=orderAmount%></div>
			<div>商户订单时间： <%=orderDatetime%> </div>
			<div>网关支付金额： <%=payAmount%></div>
			<div>网关支付时间：<%=payDatetime%></div>
			<div>signSrc报文明文:<%=srcMsg%></div>
<br>
</div>	
</html>